package com.exam.online.system.controller;

import com.exam.online.system.constant.StatusCode;
import com.exam.online.system.service.CourseService;
import com.exam.online.system.util.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.exam.online.system.constant.Constant.SERVICE_PATH_PUBLIC;

/**
 * @author yuzhen
 * @date 2019/5/8
 */
@RestController
@RequestMapping(SERVICE_PATH_PUBLIC)
public class CourseController {

    @Autowired
    private CourseService courseService;

    /**
     * 通过stuId查找课程(分页)
     */
    @PostMapping("/course/findCourseList")
    public ResponseModel findCourseList(@RequestParam("stuId") Integer stuId,
                                        @RequestParam("pageNo") Integer pageNo,
                                        @RequestParam("pageSize") Integer pageSize) {
        return ResponseModel.buildFromStateCode(StatusCode.SUCCESS, courseService.findCourseList(stuId, pageNo, pageSize));
    }

    /**
     * 查看教师和课程关系列表
     */
    @PostMapping("/course/findTeacherCourse")
    public ResponseModel findTeacherAndCourses() {
        return ResponseModel.buildFromStateCode(StatusCode.SUCCESS, courseService.findTeacherAndCourses());
    }
}
